~ chicken-core (chicken-5) /manual/Module (chicken process signal)


  1[[tags: manual]]
  2[[toc:]]
  3
  4== Module (chicken process signal)
  5
  6This module offers procedures for dealing with POSIX process signals.
  7
  8Please note that signals are very POSIX-specific.  Windows only
  9supports rudimentary in-process signals for dealing with user
 10interrupts, segmentation violations, floating-point exceptions and the
 11like.  Inter-process signals are not supported.  Therefore, most of
 12the procedures here are not available on native Windows builds.  If
 13that's the case, the description contains a note.
 14
 15
 16=== set-alarm!
 17
 18<procedure>(set-alarm! SECONDS)</procedure>
 19
 20Sets an internal timer to raise the {{signal/alrm}}
 21after {{SECONDS}} are elapsed.  You can use the
 22{{make-signal-handler}} procedure to write a handler for this signal.
 23
 24'''NOTE''': On native Windows builds (all except cygwin), this
 25procedure is unimplemented and will raise an error.
 26
 27=== make-signal-handler
 28
 29<procedure>(make-signal-handler SIGNUM ...)</procedure>
 30
 31Establishes a handler for the POSIX signals with the numbers {{SIGNUM ...}} and returns
 32a procedure of zero or one argument. Should one of the given signals be raised, then it will be stored in a
 33queue. Invoking the procedure returned by {{make-signal-handler}} with zero arguments or
 34with the argument {{#f}} will remove the oldest
 35entry in the queue and return it to the caller. Invoking the procedure with argument {{#t}} when no signal was
 36raised since the creation of the signal handler or the most recent call to the handler
 37will result in suspending the execution until one of the signals given in {{SIGNUM ...}}
 38occurs.
 39
 40Notes:
 41
 42* when signals arrive in quick succession (specifically, before the handler for a signal has been started), then signals will be queued (up to a certain limit); the order in which the queued signals will be handled is not specified
 43
 44* Any signal handlers for the signals {{signal/segv}}, {{signal/bus}}, {{signal/fpe}} and {{signal/ill}} will be ignored and these signals will always trigger an exception, unless the executable was started with the {{-:S}} runtime option. This feature is only available on platforms that support the {{sigprocmask(3)}} POSIX API function.
 45
 46=== signal-ignore
 47
 48<procedure>(signal-ignore SIGNUM)</procedure>
 49
 50Ignores any future occurrences if the signal {{SIGNUM}} by setting its disposition to {{SIG_IGN}}.
 51
 52=== signal-default
 53
 54<procedure>(signal-default SIGNUM)</procedure>
 55
 56Sets the default disposition for the signal {{SIGNUM}} by setting its disposition to {{SIG_DFL}}.
 57
 58=== set-signal-mask!
 59
 60<procedure>(set-signal-mask! SIGLIST)</procedure>
 61
 62Sets the signal mask of the current process to block all signals given
 63in the list {{SIGLIST}}.  Signals masked in that way will not be
 64delivered to the current process.
 65
 66'''NOTE''': On native Windows builds (all except cygwin), this
 67procedure is unimplemented and will raise an error.
 68
 69=== signal-mask
 70
 71<procedure>(signal-mask)</procedure>
 72
 73Returns the signal mask of the current process.
 74
 75'''NOTE''': On native Windows builds (all except cygwin), this
 76procedure is unimplemented and will raise an error.
 77
 78=== signal-masked?
 79
 80<procedure>(signal-masked? SIGNUM)</procedure>
 81
 82Returns whether the signal for the code {{SIGNUM}} is currently masked.
 83
 84'''NOTE''': On native Windows builds (all except cygwin), this
 85procedure is unimplemented and will raise an error.
 86
 87=== signal-mask!
 88
 89<procedure>(signal-mask! SIGNUM)</procedure>
 90
 91Masks (blocks) the signal for the code {{SIGNUM}}.
 92
 93'''NOTE''': On native Windows builds (all except cygwin), this
 94procedure is unimplemented and will raise an error.
 95
 96=== signal-unmask!
 97
 98<procedure>(signal-unmask! SIGNUM)</procedure>
 99
100Unmasks (unblocks) the signal for the code {{SIGNUM}}.
101
102'''NOTE''': On native Windows builds (all except cygwin), this
103procedure is unimplemented and will raise an error.
104
105=== Signal codes
106
107<constant>signal/term</constant><br>
108<constant>signal/kill</constant><br>
109<constant>signal/int</constant><br>
110<constant>signal/hup</constant><br>
111<constant>signal/fpe</constant><br>
112<constant>signal/ill</constant><br>
113<constant>signal/segv</constant><br>
114<constant>signal/abrt</constant><br>
115<constant>signal/trap</constant><br>
116<constant>signal/quit</constant><br>
117<constant>signal/alrm</constant><br>
118<constant>signal/vtalrm</constant><br>
119<constant>signal/prof</constant><br>
120<constant>signal/io</constant><br>
121<constant>signal/urg</constant><br>
122<constant>signal/chld</constant><br>
123<constant>signal/cont</constant><br>
124<constant>signal/stop</constant><br>
125<constant>signal/tstp</constant><br>
126<constant>signal/pipe</constant><br>
127<constant>signal/xcpu</constant><br>
128<constant>signal/xfsz</constant><br>
129<constant>signal/usr1</constant><br>
130<constant>signal/usr2</constant><br>
131<constant>signal/bus</constant><br>
132<constant>signal/winch</constant><br>
133<constant>signal/break</constant><br>
134<constant>signals-list</constant><br>
135
136These variables contain signal codes for use with {{process-signal}},
137{{set-signal-handler!}}, {{signal-handler}}, {{signal-masked?}},
138{{signal-mask!}}, or {{signal-unmask!}}.
139
140'''NOTE''': On native Windows builds (all except cygwin), only
141{{signal/term}}, {{signal/int}}, {{signal/fpe}}, {{signal/ill}},
142{{signal/segv}}, {{signal/abrt}}, {{signal/break}} have an actual
143value.  The others are all defined as zero, because those signals
144don't exist on Windows.
145
146'''NOTE''': On UNIX builds and cygwin, {{signal/break}} is defined as
147zero because it only exists on Windows.
148
149To get a list of signals that are known to exist on the current
150platform, you can check {{signals-list}} which is a list of integers
151(signal numbers).
152
153---
154Previous: [[Module (chicken process)]]
155
156Next: [[Module (chicken process-context)]]
Trap